|
1
|
|
|
if (!isnode()) { |
|
2
|
|
|
$(document).ready(function (e) { |
|
3
|
|
|
$(document).on("click", "[data-trigger]", function (e) { |
|
4
|
|
|
e.preventDefault(); |
|
5
|
|
|
const t = $(this); |
|
6
|
|
|
switch (t.data("trigger")) { |
|
7
|
|
|
case "modal": |
|
8
|
|
|
var target = $(t.data("target")); |
|
9
|
|
|
console.log(`open modal ${t.data("target")}`); |
|
10
|
|
|
if (target.length) { |
|
11
|
|
|
target.modal("show"); |
|
12
|
|
|
} |
|
13
|
|
|
break; |
|
14
|
|
|
} |
|
15
|
|
|
}); |
|
16
|
|
|
//href hyperlink button |
|
17
|
|
|
$(document).on("click", "button[href].btn-link", function (e) { |
|
18
|
|
|
e.preventDefault(); |
|
19
|
|
|
location.href = $(this).attr("href"); |
|
20
|
|
|
}); |
|
21
|
|
|
/** |
|
22
|
|
|
* open in new tab |
|
23
|
|
|
*/ |
|
24
|
|
|
$(document.body).on( |
|
25
|
|
|
"click", |
|
26
|
|
|
'a[id="newtab"],[newtab],[data-newtab]', |
|
27
|
|
|
function (e) { |
|
28
|
|
|
e.preventDefault(); |
|
29
|
|
|
const t = $(this); |
|
30
|
|
|
if (t.attr("href")) { |
|
31
|
|
|
if (t.data("newtab")) { |
|
32
|
|
|
//data-newtab hide referrer |
|
33
|
|
|
window |
|
34
|
|
|
.open("http://href.li/?" + $(this).data("newtab"), "newtab") |
|
35
|
|
|
.focus(); |
|
36
|
|
|
} else { |
|
37
|
|
|
openInNewTab( |
|
38
|
|
|
t.attr("href"), |
|
39
|
|
|
t.data("name") ? t.data("name") : "_blank" |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
$(document).on("click", "[data-dismiss]", function (e) { |
|
47
|
|
|
const dataDismiss = $(this).data("dismiss"); |
|
48
|
|
|
if (dataDismiss == "badge") { |
|
49
|
|
|
e.preventDefault(); |
|
50
|
|
|
console.log($(this).parents(".badge")); |
|
51
|
|
|
} |
|
52
|
|
|
}); |
|
53
|
|
|
|
|
54
|
|
|
const randbg = $(".rand-bg-color"); |
|
55
|
|
|
if (randbg.length) { |
|
56
|
|
|
randbg.each(function () { |
|
57
|
|
|
$(this).css({ |
|
58
|
|
|
background: "#" + randomHex(), |
|
59
|
|
|
color: "#ffffff", |
|
60
|
|
|
}); |
|
61
|
|
|
}); |
|
62
|
|
|
} |
|
63
|
|
|
}); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function randomHex() { |
|
67
|
|
|
return Math.floor(Math.random() * 16777215).toString(16); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* open in new tab |
|
72
|
|
|
* @param url |
|
73
|
|
|
* @param name |
|
74
|
|
|
*/ |
|
75
|
|
|
function openInNewTab(url: string, name: string) { |
|
76
|
|
|
if (typeof url != "undefined" && typeof name != "undefined") { |
|
77
|
|
|
var win = window.open(url, name); |
|
78
|
|
|
win.focus(); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|